package controller.library
{
	import events.library.EventUpdateLibraryResource;
	
	import model.ModelLibrary;
	import model.ModelProject;
	
	import org.flashIso.engine.library.objects.LBinaryData;
	import org.robotlegs.mvcs.Command;
	
	public class CommandUpdateLibraryResource extends Command
	{
		[Inject]
		public var ml:ModelLibrary;
		
		[Inject]
		public var e:EventUpdateLibraryResource;
		
		[Inject]
		public var mp:ModelProject;
		
		override public function execute() : void {
			mp.projectModified = true;
			var item:LBinaryData;
			if (e.resourceType == EventUpdateLibraryResource.TYPE_BINARY){
				item = ml.getLBinaryDataByID(e.id);
			}
			if (e.resourceType == EventUpdateLibraryResource.TYPE_IMAGE){
				item = ml.getLImageByID(e.id);
			}
			item.data = e.data;
		}
	}
}